/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.inventory.entities;

import java.io.Serializable;
import java.math.BigDecimal;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author sithum
 */
@Entity
@Table(name = "LINE_ITEM", catalog = "", schema = "APP")
@NamedQueries({@NamedQuery(name = "LineItem.findAll", query = "SELECT l FROM LineItem l"), @NamedQuery(name = "LineItem.findByLineItemId", query = "SELECT l FROM LineItem l WHERE l.lineItemId = :lineItemId"), @NamedQuery(name = "LineItem.findByQuantityUnits", query = "SELECT l FROM LineItem l WHERE l.quantityUnits = :quantityUnits"), @NamedQuery(name = "LineItem.findByQuantitySubUnits", query = "SELECT l FROM LineItem l WHERE l.quantitySubUnits = :quantitySubUnits"), @NamedQuery(name = "LineItem.findByFreeIssuedQuantity", query = "SELECT l FROM LineItem l WHERE l.freeIssuedQuantity = :freeIssuedQuantity"), @NamedQuery(name = "LineItem.findByItemDiscount", query = "SELECT l FROM LineItem l WHERE l.itemDiscount = :itemDiscount")})
public class LineItem implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "LINE_ITEM_ID", nullable = false)
    private Integer lineItemId;
    @Basic(optional = false)
    @Column(name = "QUANTITY_UNITS", nullable = false)
    private int quantityUnits;
    @Basic(optional = false)
    @Column(name = "QUANTITY_SUB_UNITS", nullable = false)
    private int quantitySubUnits;
    @Column(name = "FREE_ISSUED_QUANTITY")
    private Integer freeIssuedQuantity;
    @Column(name = "ITEM_DISCOUNT", precision = 8, scale = 2)
    private BigDecimal itemDiscount;
    @JoinColumn(name = "INVOICE_ID", referencedColumnName = "INVOICE_ID", nullable = false)
    @ManyToOne(optional = false)
    private Invoice invoiceId;
    @JoinColumn(name = "ITEM_ID", referencedColumnName = "ITEM_ID", nullable = false)
    @ManyToOne(optional = false)
    private Item itemId;

    public LineItem() {
    }

    public LineItem(Integer lineItemId) {
        this.lineItemId = lineItemId;
    }

    public LineItem(Integer lineItemId, int quantityUnits, int quantitySubUnits) {
        this.lineItemId = lineItemId;
        this.quantityUnits = quantityUnits;
        this.quantitySubUnits = quantitySubUnits;
    }

    public Integer getLineItemId() {
        return lineItemId;
    }

    public void setLineItemId(Integer lineItemId) {
        this.lineItemId = lineItemId;
    }

    public int getQuantityUnits() {
        return quantityUnits;
    }

    public void setQuantityUnits(int quantityUnits) {
        this.quantityUnits = quantityUnits;
    }

    public int getQuantitySubUnits() {
        return quantitySubUnits;
    }

    public void setQuantitySubUnits(int quantitySubUnits) {
        this.quantitySubUnits = quantitySubUnits;
    }

    public Integer getFreeIssuedQuantity() {
        return freeIssuedQuantity;
    }

    public void setFreeIssuedQuantity(Integer freeIssuedQuantity) {
        this.freeIssuedQuantity = freeIssuedQuantity;
    }

    public BigDecimal getItemDiscount() {
        return itemDiscount;
    }

    public void setItemDiscount(BigDecimal itemDiscount) {
        this.itemDiscount = itemDiscount;
    }

    public Invoice getInvoiceId() {
        return invoiceId;
    }

    public void setInvoiceId(Invoice invoiceId) {
        this.invoiceId = invoiceId;
    }

    public Item getItemId() {
        return itemId;
    }

    public void setItemId(Item itemId) {
        this.itemId = itemId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (lineItemId != null ? lineItemId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof LineItem)) {
            return false;
        }
        LineItem other = (LineItem) object;
        if ((this.lineItemId == null && other.lineItemId != null) || (this.lineItemId != null && !this.lineItemId.equals(other.lineItemId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.inventory.entities.LineItem[lineItemId=" + lineItemId + "]";
    }

}
